layui.define(['layer', 'form'], function (exports) {
    async function loadJS(url) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        var t = document.getElementsByTagName('head')[0].appendChild(script);
        script.src = url;
        return new Promise((resolve, reject) => {
            script.onload = function () {
                document.getElementsByTagName('head')[0].removeChild(script);
                resolve(window.axios);
            };
        })
    }

    var axios = null;

    async function hello() {
        if (!axios) {
            axios = await loadJS("https://unpkg.com/axios/dist/axios.min.js");
        }
        return axios.request({
            url: "http://t7.baidu.com/it/u=3225540498,2642373837&fm=79&app=86&f=JPEG?w=1162&h=1800",
            method: 'get',
            responseType: 'blob'
        }).then(data => data.data);
    }

    exports('webApi', {hello}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
})
;
